# -------------------Compiler & Flags------------------------------------------
F90COMPILER = gfortran 
F90LINKER   = gfortran 
F90COMPILEOPTS=-O2 -fPIC 
F90COMPILEPATHS=
#F90COMPILECPPFLAGS=-DDEBUG=1 -DNETCDF=1 -DPNETCDF=1
F90COMPILECPPFLAGS=
F90LINKOPTS= 
#F90LINKPATHS=-L/home/hxm/esm-soft/lib -L/apps/intel/2013Compiler/mkl/lib/intel64 
F90LINKPATHS=
F90LINKLIBS=

# -----------------------------------------------------------------------------
SRCDIR =  src

VPATH= $(SRCDIR)

.SUFFIXES: .F .f .f90 .F90 

%.o : %.f90
	$(F90COMPILER) -c $(F90COMPILEOPTS) $(F90COMPILEPATHS) $<

%.o : %.F90
	$(F90COMPILER) -c $(F90COMPILEOPTS) $(F90COMPILEPATHS) $(F90COMPILECPPFLAGS) $<
 
%.o : %.f
	$(F90COMPILER) -c $(F90COMPILEOPTS) $(F90COMPILEPATHS) $<
 
%.o : %.F
	$(F90COMPILER) -c $(F90COMPILEOPTS) $(F90COMPILEPATHS) $(F90COMPILECPPFLAGS) $<
       
      
# -----------------------------------------------------------------------------
shallow.exe: module_para.o module_array.o cs.o dif.o euler.o haurwitz.o  main.o
	$(F90LINKER) $(F90LINKOPTS) $(F90LINKPATHS) -o $@ $^ $(F90LINKLIBS)
#module dependencies:
#main.o: ocean_mod.o
#ocean_mod.o: FlowSolverMod.o InjectorMod.o CouplerMod.o

# -----------------------------------------------------------------------------
.PHONY: dust clean distclean
dust:
	rm -f *.log 
clean:
	rm -f *.exe *.o *.mod
distclean: dust clean

run:
	make
	./shallow.exe
